#include "sys.h"
#include "pvd.h"
#include "Control.h"

u8 PVD_Init(void)
{
   EXTI_InitTypeDef EXTI_InitStructure;
	NVIC_InitTypeDef NVIC_InitStruct;

	RCC_APB1PeriphClockCmd( RCC_APB1Periph_PWR, ENABLE); 
	PWR_PVDLevelConfig(PWR_PVDLevel_2V9); 

	NVIC_InitStruct.NVIC_IRQChannel = PVD_IRQn;
	NVIC_InitStruct.NVIC_IRQChannelPreemptionPriority = 0;
	NVIC_InitStruct.NVIC_IRQChannelSubPriority = 0;
	NVIC_InitStruct.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStruct);
	
  PWR_PVDLevelConfig(PWR_PVDLevel_2V9); 

  PWR_PVDCmd(ENABLE); 
	
  EXTI_StructInit(&EXTI_InitStructure);

  EXTI_InitStructure.EXTI_Line = EXTI_Line16; 

  EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt; 

  EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;

  EXTI_InitStructure.EXTI_LineCmd = ENABLE; 

  EXTI_Init(&EXTI_InitStructure); 

return 0;
}


void PVD_IRQHandler(void)

{

  EXTI_ClearITPendingBit(EXTI_Line16);
	
	JDKRC_LowVSaveValue();
}


